package com.ropeok.config;

import com.baomidou.mybatisplus.core.injector.ISqlInjector;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @BelongsProject: training-mission
 * @BelongsPackage: com.ropeok.config
 * @Author: zhofeifan
 * @CreateTime: 2022-09-27  10:30
 * @Description: TODO
 * @Version: 1.0
 */
@MapperScan("com.ropeok.mapper")//扫描mapper文件
@EnableTransactionManagement
@Configuration//配置类
public class MyBatisPlusConfig {
    //注册乐观锁插件
    @Bean
    public OptimisticLockerInnerInterceptor optimisticLockerInnerInterceptor(){
        return  new OptimisticLockerInnerInterceptor();
    }
    //分页插件
    @Bean
    public PaginationInterceptor paginationInnerceptor(){
       return new PaginationInterceptor();
    }
//    @Bean
//    public ISqlInjector sqlInjector(){
//        return new LogicSqlInjector();
//    }
}
